clear all ; clc; close all;
global TauChip;
TauChip = 1;
Tc = 0.02;
% Интервал накопления, s
qcno_dB = 15:25;
% SNR, dBHz
stdn_IQ = 8;
% СКО шума квадратур
EpsW= 0;
EpsTau = 0;
Nexp = 1e7;
bits = randn(1, Nexp) > 0;
EpsPhi = bits * pi;
nI = stdn_IQ*randn(1,Nexp);
for j = 1:length(qcno_dB)
[A_IQ qcno] = qcno_change(qcno_dB(j), stdn_IQ, Tc);
A_IQ_eff = A_IQ*sinc(EpsW*Tc/2 /pi)*ro(EpsTau);
mI = A_IQ_eff * cos(EpsW*Tc/2 + EpsPhi); I = mI + nI;
bits_est = (I < 0);
BER(j) = sum(bits_est ~= bits) / Nexp;
end
q = 10.^(qcno_dB/10) * Tc; BER_teor = 0.5 * erfc(sqrt(q));
q_dB = 10*log10(q);
figure(1); semilogy(q_dB, BER, q_dB, BER_teor);
xlabel('q, dB');
ylabel('BER'); 
grid on;